package com.ruoyi.project.fit.controller;


import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.fit.domain.Cost;
import com.ruoyi.project.fit.domain.FitDept;
import com.ruoyi.project.fit.domain.FitRegisterMoney;
import com.ruoyi.project.fit.service.FitRegisterMoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/fit/money")
public class FitRegisterMoneyController extends BaseController {

    @Autowired
    private FitRegisterMoneyService fitRegisterMoneyService;

    //删除挂号费用
    @PreAuthorize("@ss.hasPermi('fit:money:remove')")
    @Log(title = "检查费用", businessType = BusinessType.DELETE)
    @DeleteMapping("/{monIds}")
    public AjaxResult remove(@PathVariable Long[] monIds) {

        return toAjax(fitRegisterMoneyService.deleteFitRegisterMoneyByIds(monIds));
    }

    //修改挂号费用

    @PreAuthorize("@ss.hasPermi('fit:money:edit')")
    @Log(title = "挂号费用", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody FitRegisterMoney fitRegisterMoney) {

        fitRegisterMoney.setUpdateBy(SecurityUtils.getUsername());
        return toAjax(fitRegisterMoneyService.updateFitRegisterMoney(fitRegisterMoney));
    }

    //新增
    @PreAuthorize("@ss.hasPermi('fit:money:add')")
    @Log(title = "挂号费用", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody FitRegisterMoney fitRegisterMoney) {
        fitRegisterMoney.setCreateBy(SecurityUtils.getUsername());
        return toAjax(fitRegisterMoneyService.insertFitRegisterMoney(fitRegisterMoney));
    }
    /**
     * 根据挂号费用编号获取详细信息
     */
    @PreAuthorize("@ss.hasPermi('fit:money:query')")
    @GetMapping(value = "/{monId}")
    public AjaxResult getInfo(@PathVariable Long monId) {
        return AjaxResult.success(fitRegisterMoneyService.selectFitRegisterMoneyById(monId));
    }

    /**
     * 获取挂号费用列表
     */
    @PreAuthorize("@ss.hasPermi('fit:money:list')")
    @GetMapping("/list")
    public TableDataInfo list(Integer pageNum, Integer pageSize,FitRegisterMoney fitRegisterMoney) {

        startPage();
        List<FitRegisterMoney> list = fitRegisterMoneyService.selectFitRegisterMoneyList(fitRegisterMoney);
        return getDataTable(list);
    }
}
